//<!--Created by 王童 on 2018/5/24-->
package cn.yunhe.controller;

import cn.yunhe.entity.Course;
import cn.yunhe.entity.Point;
import cn.yunhe.entity.Problem;
import cn.yunhe.entity.Type;
import cn.yunhe.services.WtIStuServices;
import com.github.pagehelper.Page;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2018/5/23.
 */
@RestController
@RequestMapping("/practice")
public class WtStuController {
        @Resource
        private WtIStuServices stuServices;


        @RequestMapping("/getlists")
        public ModelAndView problem(){
            ModelAndView mv = new ModelAndView();
            List<Problem> list= stuServices.getGrade();
            List<Point> list1=stuServices.getAllPoint();
            List<Course> list2=stuServices.getAlls();
            mv.addObject("list",list);
            mv.addObject("list1",list1);
            mv.addObject("list2",list2);
            mv.setViewName("student/strengthenPrac");
            return mv;
        }

    @RequestMapping("/toPage")
    public ModelAndView toPage(int point_id, int grade){
    ModelAndView mv = new ModelAndView("student/strengthenPracPage");
        mv.addObject("point_id",point_id);
        mv.addObject("grade",grade);
        return mv;
    }
    @RequestMapping("/getlist")
    public Map problems(Integer pageNum, Integer pageSize, Problem problem, Type type){
        Map map=new HashMap();
        map.put("pageSize", pageSize);
        map.put("pageNum", pageNum);
        map.put("problem", problem);
        map.put("type",type);
        Page page=stuServices.queryLikeProblems(map);
        map.put("page",page);
        map.put("totalPage",page.getPages());
        return map;
    }
}


